package solver;

import java.util.Random;

public class Commutator333 {
	private static boolean ini = false;
	private String sol;
	private String[] steps = new String[6];

	private static Random r = new Random();

	private class directLayer
	{
		String theMove;
		int theDest;
	};

	private directLayer[][] m_astDirectLayers;
	private directLayer[][] m_astDirectCornerLayers;

	/*
				4   5   7
				3       7
				1   1   10
	5   4   3   2   2   12  11  8   9   8   6   6
	22      20  19      17  18      24  23      21
	18  12  14  15  10  23  24  16  20  21  14  17
				13  9   22
				11      15
				16  13  19
	*/
	private void fill_directLayer(int i, int j, String theMove, int theDest)
	{
		directLayer layer = new directLayer();
		layer.theMove = theMove;
		layer.theDest = theDest;
		m_astDirectLayers[i][j] = layer;
	}

	private void fill_directLayerCorner(int i, int j, String theMove, int theDest)
	{
		directLayer layer = new directLayer();
		layer.theMove = theMove;
		layer.theDest = theDest;
		m_astDirectCornerLayers[i][j] = layer;
	}

	private void init()
	{
		init_corners();
		init_edges();
	}

	private void init_corners()
	{
		int i, j;

		m_astDirectCornerLayers = new directLayer[25][9];

		i = 1;
		j = 0;
		fill_directLayerCorner(i, j++, "F", 11);
		fill_directLayerCorner(i, j++, "F2", 22);
		fill_directLayerCorner(i, j++, "F'", 14);
		fill_directLayerCorner(i, j++, "L", 15);
		fill_directLayerCorner(i, j++, "L2", 16);
		fill_directLayerCorner(i, j++, "L'", 6);
		fill_directLayerCorner(i, j++, "U", 4);
		fill_directLayerCorner(i, j++, "U2", 7);
		fill_directLayerCorner(i, j++, "U'", 10);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "F", 12);
		fill_directLayerCorner(i, j++, "F2", 23);
		fill_directLayerCorner(i, j++, "F'", 15);
		fill_directLayerCorner(i, j++, "L", 13);
		fill_directLayerCorner(i, j++, "L2", 17);
		fill_directLayerCorner(i, j++, "L'", 4);
		fill_directLayerCorner(i, j++, "U", 5);
		fill_directLayerCorner(i, j++, "U2", 8);
		fill_directLayerCorner(i, j++, "U'", 11);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "F", 10);
		fill_directLayerCorner(i, j++, "F2", 24);
		fill_directLayerCorner(i, j++, "F'", 13);
		fill_directLayerCorner(i, j++, "L", 14);
		fill_directLayerCorner(i, j++, "L2", 18);
		fill_directLayerCorner(i, j++, "L'", 5);
		fill_directLayerCorner(i, j++, "U", 6);
		fill_directLayerCorner(i, j++, "U2", 9);
		fill_directLayerCorner(i, j++, "U'", 12);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "B", 18);
		fill_directLayerCorner(i, j++, "B2", 19);
		fill_directLayerCorner(i, j++, "B'", 9);
		fill_directLayerCorner(i, j++, "U", 7);
		fill_directLayerCorner(i, j++, "U2", 10);
		fill_directLayerCorner(i, j++, "U'", 1);
		fill_directLayerCorner(i, j++, "L", 2);
		fill_directLayerCorner(i, j++, "L2", 13);
		fill_directLayerCorner(i, j++, "L'", 17);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "B", 16);
		fill_directLayerCorner(i, j++, "B2", 21);
		fill_directLayerCorner(i, j++, "B'", 7);
		fill_directLayerCorner(i, j++, "U", 8);
		fill_directLayerCorner(i, j++, "U2", 11);
		fill_directLayerCorner(i, j++, "U'", 2);
		fill_directLayerCorner(i, j++, "L", 3);
		fill_directLayerCorner(i, j++, "L2", 14);
		fill_directLayerCorner(i, j++, "L'", 18);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "B", 17);
		fill_directLayerCorner(i, j++, "B2", 20);
		fill_directLayerCorner(i, j++, "B'", 8);
		fill_directLayerCorner(i, j++, "U", 9);
		fill_directLayerCorner(i, j++, "U2", 12);
		fill_directLayerCorner(i, j++, "U'", 3);
		fill_directLayerCorner(i, j++, "L", 1);
		fill_directLayerCorner(i, j++, "L2", 15);
		fill_directLayerCorner(i, j++, "L'", 16);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "B", 5);
		fill_directLayerCorner(i, j++, "B2", 16);
		fill_directLayerCorner(i, j++, "B'", 20);
		fill_directLayerCorner(i, j++, "U", 10);
		fill_directLayerCorner(i, j++, "U2", 1);
		fill_directLayerCorner(i, j++, "U'", 4);
		fill_directLayerCorner(i, j++, "R", 21);
		fill_directLayerCorner(i, j++, "R2", 22);
		fill_directLayerCorner(i, j++, "R'", 12);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "B", 6);
		fill_directLayerCorner(i, j++, "B2", 17);
		fill_directLayerCorner(i, j++, "B'", 21);
		fill_directLayerCorner(i, j++, "U", 11);
		fill_directLayerCorner(i, j++, "U2", 2);
		fill_directLayerCorner(i, j++, "U'", 5);
		fill_directLayerCorner(i, j++, "R", 19);
		fill_directLayerCorner(i, j++, "R2", 23);
		fill_directLayerCorner(i, j++, "R'", 10);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "B", 4);
		fill_directLayerCorner(i, j++, "B2", 18);
		fill_directLayerCorner(i, j++, "B'", 19);
		fill_directLayerCorner(i, j++, "U", 12);
		fill_directLayerCorner(i, j++, "U2", 3);
		fill_directLayerCorner(i, j++, "U'", 6);
		fill_directLayerCorner(i, j++, "R", 20);
		fill_directLayerCorner(i, j++, "R2", 24);
		fill_directLayerCorner(i, j++, "R'", 11);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "F", 24);
		fill_directLayerCorner(i, j++, "F2", 13);
		fill_directLayerCorner(i, j++, "F'", 3);
		fill_directLayerCorner(i, j++, "U", 1);
		fill_directLayerCorner(i, j++, "U2", 4);
		fill_directLayerCorner(i, j++, "U'", 7);
		fill_directLayerCorner(i, j++, "R", 8);
		fill_directLayerCorner(i, j++, "R2", 19);
		fill_directLayerCorner(i, j++, "R'", 23);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "F", 22);
		fill_directLayerCorner(i, j++, "F2", 14);
		fill_directLayerCorner(i, j++, "F'", 1);
		fill_directLayerCorner(i, j++, "U", 2);
		fill_directLayerCorner(i, j++, "U2", 5);
		fill_directLayerCorner(i, j++, "U'", 8);
		fill_directLayerCorner(i, j++, "R", 9);
		fill_directLayerCorner(i, j++, "R2", 20);
		fill_directLayerCorner(i, j++, "R'", 24);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "F", 23);
		fill_directLayerCorner(i, j++, "F2", 15);
		fill_directLayerCorner(i, j++, "F'", 2);
		fill_directLayerCorner(i, j++, "U", 3);
		fill_directLayerCorner(i, j++, "U2", 6);
		fill_directLayerCorner(i, j++, "U'", 9);
		fill_directLayerCorner(i, j++, "R", 7);
		fill_directLayerCorner(i, j++, "R2", 21);
		fill_directLayerCorner(i, j++, "R'", 22);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "L", 17);
		fill_directLayerCorner(i, j++, "L2", 4);
		fill_directLayerCorner(i, j++, "L'", 2);
		fill_directLayerCorner(i, j++, "F", 3);
		fill_directLayerCorner(i, j++, "F2", 10);
		fill_directLayerCorner(i, j++, "F'", 24);
		fill_directLayerCorner(i, j++, "D", 22);
		fill_directLayerCorner(i, j++, "D2", 19);
		fill_directLayerCorner(i, j++, "D'", 16);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "L", 18);
		fill_directLayerCorner(i, j++, "L2", 5);
		fill_directLayerCorner(i, j++, "L'", 3);
		fill_directLayerCorner(i, j++, "F", 1);
		fill_directLayerCorner(i, j++, "F2", 11);
		fill_directLayerCorner(i, j++, "F'", 22);
		fill_directLayerCorner(i, j++, "D", 23);
		fill_directLayerCorner(i, j++, "D2", 20);
		fill_directLayerCorner(i, j++, "D'", 17);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "L", 16);
		fill_directLayerCorner(i, j++, "L2", 6);
		fill_directLayerCorner(i, j++, "L'", 1);
		fill_directLayerCorner(i, j++, "F", 2);
		fill_directLayerCorner(i, j++, "F2", 12);
		fill_directLayerCorner(i, j++, "F'", 23);
		fill_directLayerCorner(i, j++, "D", 24);
		fill_directLayerCorner(i, j++, "D2", 21);
		fill_directLayerCorner(i, j++, "D'", 18);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "L", 6);
		fill_directLayerCorner(i, j++, "L2", 1);
		fill_directLayerCorner(i, j++, "L'", 15);
		fill_directLayerCorner(i, j++, "B", 21);
		fill_directLayerCorner(i, j++, "B2", 7);
		fill_directLayerCorner(i, j++, "B'", 5);
		fill_directLayerCorner(i, j++, "D", 13);
		fill_directLayerCorner(i, j++, "D2", 22);
		fill_directLayerCorner(i, j++, "D'", 19);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "L", 4);
		fill_directLayerCorner(i, j++, "L2", 2);
		fill_directLayerCorner(i, j++, "L'", 13);
		fill_directLayerCorner(i, j++, "B", 20);
		fill_directLayerCorner(i, j++, "B2", 8);
		fill_directLayerCorner(i, j++, "B'", 6);
		fill_directLayerCorner(i, j++, "D", 14);
		fill_directLayerCorner(i, j++, "D2", 23);
		fill_directLayerCorner(i, j++, "D'", 20);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "L", 5);
		fill_directLayerCorner(i, j++, "L2", 3);
		fill_directLayerCorner(i, j++, "L'", 14);
		fill_directLayerCorner(i, j++, "B", 19);
		fill_directLayerCorner(i, j++, "B2", 9);
		fill_directLayerCorner(i, j++, "B'", 4);
		fill_directLayerCorner(i, j++, "D", 15);
		fill_directLayerCorner(i, j++, "D2", 24);
		fill_directLayerCorner(i, j++, "D'", 21);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "B", 9);
		fill_directLayerCorner(i, j++, "B2", 4);
		fill_directLayerCorner(i, j++, "B'", 18);
		fill_directLayerCorner(i, j++, "R", 23);
		fill_directLayerCorner(i, j++, "R2", 10);
		fill_directLayerCorner(i, j++, "R'", 8);
		fill_directLayerCorner(i, j++, "D", 16);
		fill_directLayerCorner(i, j++, "D2", 13);
		fill_directLayerCorner(i, j++, "D'", 22);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "B", 7);
		fill_directLayerCorner(i, j++, "B2", 5);
		fill_directLayerCorner(i, j++, "B'", 16);
		fill_directLayerCorner(i, j++, "R", 24);
		fill_directLayerCorner(i, j++, "R2", 11);
		fill_directLayerCorner(i, j++, "R'", 9);
		fill_directLayerCorner(i, j++, "D", 17);
		fill_directLayerCorner(i, j++, "D2", 14);
		fill_directLayerCorner(i, j++, "D'", 24);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "B", 8);
		fill_directLayerCorner(i, j++, "B2", 6);
		fill_directLayerCorner(i, j++, "B'", 17);
		fill_directLayerCorner(i, j++, "R", 22);
		fill_directLayerCorner(i, j++, "R2", 12);
		fill_directLayerCorner(i, j++, "R'", 7);
		fill_directLayerCorner(i, j++, "D", 18);
		fill_directLayerCorner(i, j++, "D2", 15);
		fill_directLayerCorner(i, j++, "D'", 24);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "F", 14);
		fill_directLayerCorner(i, j++, "F2", 1);
		fill_directLayerCorner(i, j++, "F'", 11);
		fill_directLayerCorner(i, j++, "R", 12);
		fill_directLayerCorner(i, j++, "R2", 7);
		fill_directLayerCorner(i, j++, "R'", 21);
		fill_directLayerCorner(i, j++, "D", 19);
		fill_directLayerCorner(i, j++, "D2", 16);
		fill_directLayerCorner(i, j++, "D'", 13);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "F", 15);
		fill_directLayerCorner(i, j++, "F2", 2);
		fill_directLayerCorner(i, j++, "F'", 12);
		fill_directLayerCorner(i, j++, "R", 10);
		fill_directLayerCorner(i, j++, "R2", 8);
		fill_directLayerCorner(i, j++, "R'", 19);
		fill_directLayerCorner(i, j++, "D", 20);
		fill_directLayerCorner(i, j++, "D2", 17);
		fill_directLayerCorner(i, j++, "D'", 14);

		i++;
		j = 0;
		fill_directLayerCorner(i, j++, "F", 13);
		fill_directLayerCorner(i, j++, "F2", 3);
		fill_directLayerCorner(i, j++, "F'", 10);
		fill_directLayerCorner(i, j++, "R", 11);
		fill_directLayerCorner(i, j++, "R2", 9);
		fill_directLayerCorner(i, j++, "R'", 20);
		fill_directLayerCorner(i, j++, "D", 21);
		fill_directLayerCorner(i, j++, "D2", 18);
		fill_directLayerCorner(i, j++, "D'", 15);
	}

	private void init_edges()
	{
		int i, j;

		m_astDirectLayers = new directLayer[25][9];

		i = 1;
		j = 0;
		fill_directLayer(i, j++, "U", 3);
		fill_directLayer(i, j++, "U2", 5);
		fill_directLayer(i, j++, "U'", 7);
		fill_directLayer(i, j++, "F", 18);
		fill_directLayer(i, j++, "F2", 9);
		fill_directLayer(i, j++, "F'", 20);
		fill_directLayer(i, j++, "M", 10);
		fill_directLayer(i, j++, "M2", 13);
		fill_directLayer(i, j++, "M'", 6);

		i++;
		j = 0;
		fill_directLayer(i, j++, "U", 4);
		fill_directLayer(i, j++, "U2", 6);
		fill_directLayer(i, j++, "U'", 8);
		fill_directLayer(i, j++, "F", 17);
		fill_directLayer(i, j++, "F2", 10);
		fill_directLayer(i, j++, "F'", 19);
		fill_directLayer(i, j++, "M", 9);
		fill_directLayer(i, j++, "M2", 14);
		fill_directLayer(i, j++, "M'", 5);

		i++;
		j = 0;
		fill_directLayer(i, j++, "L", 19);
		fill_directLayer(i, j++, "L2", 11);
		fill_directLayer(i, j++, "L'", 21);
		fill_directLayer(i, j++, "U", 5);
		fill_directLayer(i, j++, "U2", 7);
		fill_directLayer(i, j++, "U'", 1);
		fill_directLayer(i, j++, "S", 8);
		fill_directLayer(i, j++, "S2", 15);
		fill_directLayer(i, j++, "S'", 12);

		i++;
		j = 0;
		fill_directLayer(i, j++, "L", 20);
		fill_directLayer(i, j++, "L2", 12);
		fill_directLayer(i, j++, "L'", 22);
		fill_directLayer(i, j++, "U", 6);
		fill_directLayer(i, j++, "U2", 8);
		fill_directLayer(i, j++, "U'", 2);
		fill_directLayer(i, j++, "S", 7);
		fill_directLayer(i, j++, "S2", 16);
		fill_directLayer(i, j++, "S'", 11);

		i++;
		j = 0;
		fill_directLayer(i, j++, "B", 22);
		fill_directLayer(i, j++, "B2", 13);
		fill_directLayer(i, j++, "B'", 24);
		fill_directLayer(i, j++, "U", 7);
		fill_directLayer(i, j++, "U2", 1);
		fill_directLayer(i, j++, "U'", 3);
		fill_directLayer(i, j++, "M", 2);
		fill_directLayer(i, j++, "M2", 9);
		fill_directLayer(i, j++, "M'", 14);

		i++;
		j = 0;
		fill_directLayer(i, j++, "B", 21);
		fill_directLayer(i, j++, "B2", 14);
		fill_directLayer(i, j++, "B'", 23);
		fill_directLayer(i, j++, "U", 8);
		fill_directLayer(i, j++, "U2", 2);
		fill_directLayer(i, j++, "U'", 4);
		fill_directLayer(i, j++, "M", 1);
		fill_directLayer(i, j++, "M2", 10);
		fill_directLayer(i, j++, "M'", 13);

		i++;
		j = 0;
		fill_directLayer(i, j++, "R", 23);
		fill_directLayer(i, j++, "R2", 15);
		fill_directLayer(i, j++, "R'", 17);
		fill_directLayer(i, j++, "U", 1);
		fill_directLayer(i, j++, "U2", 3);
		fill_directLayer(i, j++, "U'", 5);
		fill_directLayer(i, j++, "S", 16);
		fill_directLayer(i, j++, "S2", 11);
		fill_directLayer(i, j++, "S'", 4);

		i++;
		j = 0;
		fill_directLayer(i, j++, "R", 24);
		fill_directLayer(i, j++, "R2", 16);
		fill_directLayer(i, j++, "R'", 18);
		fill_directLayer(i, j++, "U", 2);
		fill_directLayer(i, j++, "U2", 4);
		fill_directLayer(i, j++, "U'", 6);
		fill_directLayer(i, j++, "S", 15);
		fill_directLayer(i, j++, "S2", 12);
		fill_directLayer(i, j++, "S'", 3);

		i++;
		j = 0;
		fill_directLayer(i, j++, "F", 20);
		fill_directLayer(i, j++, "F2", 1);
		fill_directLayer(i, j++, "F'", 18);
		fill_directLayer(i, j++, "D", 15);
		fill_directLayer(i, j++, "D2", 13);
		fill_directLayer(i, j++, "D'", 11);
		fill_directLayer(i, j++, "M", 14);
		fill_directLayer(i, j++, "M2", 5);
		fill_directLayer(i, j++, "M'", 2);

		i++;
		j = 0;
		fill_directLayer(i, j++, "F", 19);
		fill_directLayer(i, j++, "F2", 2);
		fill_directLayer(i, j++, "F'", 17);
		fill_directLayer(i, j++, "D", 16);
		fill_directLayer(i, j++, "D2", 14);
		fill_directLayer(i, j++, "D'", 12);
		fill_directLayer(i, j++, "M", 13);
		fill_directLayer(i, j++, "M2", 6);
		fill_directLayer(i, j++, "M'", 1);

		i++;
		j = 0;
		fill_directLayer(i, j++, "L", 21);
		fill_directLayer(i, j++, "L2", 3);
		fill_directLayer(i, j++, "L'", 19);
		fill_directLayer(i, j++, "D", 9);
		fill_directLayer(i, j++, "D2", 15);
		fill_directLayer(i, j++, "D'", 13);
		fill_directLayer(i, j++, "S", 4);
		fill_directLayer(i, j++, "S2", 7);
		fill_directLayer(i, j++, "S'", 16);

		i++;
		j = 0;
		fill_directLayer(i, j++, "L", 22);
		fill_directLayer(i, j++, "L2", 4);
		fill_directLayer(i, j++, "L'", 20);
		fill_directLayer(i, j++, "D", 10);
		fill_directLayer(i, j++, "D2", 16);
		fill_directLayer(i, j++, "D'", 14);
		fill_directLayer(i, j++, "S", 3);
		fill_directLayer(i, j++, "S2", 8);
		fill_directLayer(i, j++, "S'", 15);

		i++;
		j = 0;
		fill_directLayer(i, j++, "B", 24);
		fill_directLayer(i, j++, "B2", 5);
		fill_directLayer(i, j++, "B'", 22);
		fill_directLayer(i, j++, "D", 11);
		fill_directLayer(i, j++, "D2", 9);
		fill_directLayer(i, j++, "D'", 15);
		fill_directLayer(i, j++, "M", 6);
		fill_directLayer(i, j++, "M2", 1);
		fill_directLayer(i, j++, "M'", 10);

		i++;
		j = 0;
		fill_directLayer(i, j++, "B", 23);
		fill_directLayer(i, j++, "B2", 6);
		fill_directLayer(i, j++, "B'", 21);
		fill_directLayer(i, j++, "D", 12);
		fill_directLayer(i, j++, "D2", 10);
		fill_directLayer(i, j++, "D'", 16);
		fill_directLayer(i, j++, "M", 5);
		fill_directLayer(i, j++, "M2", 2);
		fill_directLayer(i, j++, "M'", 9);

		i++;
		j = 0;
		fill_directLayer(i, j++, "R", 17);
		fill_directLayer(i, j++, "R2", 7);
		fill_directLayer(i, j++, "R'", 23);
		fill_directLayer(i, j++, "D", 13);
		fill_directLayer(i, j++, "D2", 11);
		fill_directLayer(i, j++, "D'", 9);
		fill_directLayer(i, j++, "S", 12);
		fill_directLayer(i, j++, "S2", 3);
		fill_directLayer(i, j++, "S'", 8);

		i++;
		j = 0;
		fill_directLayer(i, j++, "R", 18);
		fill_directLayer(i, j++, "R2", 8);
		fill_directLayer(i, j++, "R'", 24);
		fill_directLayer(i, j++, "D", 14);
		fill_directLayer(i, j++, "D2", 12);
		fill_directLayer(i, j++, "D'", 10);
		fill_directLayer(i, j++, "S", 11);
		fill_directLayer(i, j++, "S2", 4);
		fill_directLayer(i, j++, "S'", 7);

		i++;
		j = 0;
		fill_directLayer(i, j++, "R", 7);
		fill_directLayer(i, j++, "R2", 23);
		fill_directLayer(i, j++, "R'", 15);
		fill_directLayer(i, j++, "E", 24);
		fill_directLayer(i, j++, "E2", 21);
		fill_directLayer(i, j++, "E'", 20);
		fill_directLayer(i, j++, "F", 10);
		fill_directLayer(i, j++, "F2", 19);
		fill_directLayer(i, j++, "F'", 2);

		i++;
		j = 0;
		fill_directLayer(i, j++, "R", 8);
		fill_directLayer(i, j++, "R2", 24);
		fill_directLayer(i, j++, "R'", 16);
		fill_directLayer(i, j++, "E", 23);
		fill_directLayer(i, j++, "E2", 22);
		fill_directLayer(i, j++, "E'", 19);
		fill_directLayer(i, j++, "F", 9);
		fill_directLayer(i, j++, "F2", 20);
		fill_directLayer(i, j++, "F'", 1);

		i++;
		j = 0;
		fill_directLayer(i, j++, "L", 11);
		fill_directLayer(i, j++, "L2", 21);
		fill_directLayer(i, j++, "L'", 3);
		fill_directLayer(i, j++, "E", 18);
		fill_directLayer(i, j++, "E2", 23);
		fill_directLayer(i, j++, "E'", 22);
		fill_directLayer(i, j++, "F", 2);
		fill_directLayer(i, j++, "F2", 17);
		fill_directLayer(i, j++, "F'", 10);

		i++;
		j = 0;
		fill_directLayer(i, j++, "L", 12);
		fill_directLayer(i, j++, "L2", 22);
		fill_directLayer(i, j++, "L'", 4);
		fill_directLayer(i, j++, "E", 17);
		fill_directLayer(i, j++, "E2", 24);
		fill_directLayer(i, j++, "E'", 21);
		fill_directLayer(i, j++, "F", 1);
		fill_directLayer(i, j++, "F2", 18);
		fill_directLayer(i, j++, "F'", 9);

		i++;
		j = 0;
		fill_directLayer(i, j++, "L", 3);
		fill_directLayer(i, j++, "L2", 19);
		fill_directLayer(i, j++, "L'", 11);
		fill_directLayer(i, j++, "E", 20);
		fill_directLayer(i, j++, "E2", 17);
		fill_directLayer(i, j++, "E'", 24);
		fill_directLayer(i, j++, "B", 14);
		fill_directLayer(i, j++, "B2", 23);
		fill_directLayer(i, j++, "B'", 6);

		i++;
		j = 0;
		fill_directLayer(i, j++, "L", 4);
		fill_directLayer(i, j++, "L2", 20);
		fill_directLayer(i, j++, "L'", 12);
		fill_directLayer(i, j++, "E", 19);
		fill_directLayer(i, j++, "E2", 18);
		fill_directLayer(i, j++, "E'", 23);
		fill_directLayer(i, j++, "B", 13);
		fill_directLayer(i, j++, "B2", 24);
		fill_directLayer(i, j++, "B'", 5);

		i++;
		j = 0;
		fill_directLayer(i, j++, "R", 15);
		fill_directLayer(i, j++, "R2", 17);
		fill_directLayer(i, j++, "R'", 7);
		fill_directLayer(i, j++, "E", 22);
		fill_directLayer(i, j++, "E2", 19);
		fill_directLayer(i, j++, "E'", 18);
		fill_directLayer(i, j++, "B", 6);
		fill_directLayer(i, j++, "B2", 21);
		fill_directLayer(i, j++, "B'", 14);

		i++;
		j = 0;
		fill_directLayer(i, j++, "R", 16);
		fill_directLayer(i, j++, "R2", 18);
		fill_directLayer(i, j++, "R'", 8);
		fill_directLayer(i, j++, "E", 21);
		fill_directLayer(i, j++, "E2", 20);
		fill_directLayer(i, j++, "E'", 17);
		fill_directLayer(i, j++, "B", 5);
		fill_directLayer(i, j++, "B2", 22);
		fill_directLayer(i, j++, "B'", 13);
	}

	public Commutator333() {
		if(!ini) {
			init();
			ini = true;
		}
	}

	String calc_switch_layers(char layer)
	{
		String result = "";

		switch ( layer )
		{
			case 'R':
				result = "ML";
				break;

			case 'M':
				result = "RL";
				break;

			case 'L':
				result = "MR";
				break;

			case 'U':
				result = "ED";
				break;

			case 'E':
				result = "UD";
				break;

			case 'D':
				result = "EU";
				break;

			case 'F':
				result = "BS";
				break;

			case 'S':
				result = "FB";
				break;

			case 'B':
				result = "FS";
				break;

			default:
				break;
		}

		return result;
	}

	String calc_switch_layers_corner(char layer)
	{
		String result = "";

		switch ( layer )
		{
			case 'R':
				result = "L";
				break;

			case 'L':
				result = "R";
				break;

			case 'U':
				result = "D";
				break;

			case 'D':
				result = "U";
				break;

			case 'F':
				result = "B";
				break;

			case 'B':
				result = "F";
				break;

			default:
				break;
		}

		return result;
	}

	String reverse_move(String themove)
	{
		String[] temp = themove.split(" ");
		String result = "";

		for (int i = temp.length - 1; i >= 0; i--)
		{
			if ( 1 == temp[i].length() )
			{
				result += " " + (temp[i] + "'");
			}
			else if ( '\'' == temp[i].charAt(1) )
			{
				result += " " + temp[i].substring(0,1);
			}
			else {
				result += " " + temp[i];
			}
		}

		return result.substring(1);
	}

	public String scramble(int type) {
		try {
			if ( 0 == type )
			{
				return scramble_edge();
			}

			return scramble_corner();
		}
		catch (Exception e)
		{
			System.out.println(e.toString());
		}

		steps[0] = "null";
		steps[1] = "null";
		steps[2] = "null";
		steps[3] = "null";
		steps[4] = "null";
		steps[5] = "null";

		return "";
	}

	private String scramble_corner() {
		int aiFaces[] = new int[3];
		String pcDirectLayerMove = null;
		int iSecondFace, iTemp, iSwitchDirectFace, iDirectOtherFace, iSwitchOthreFace, i, j, k, iSwitchLayer, iCount, iCount2, iCount3;
		String acSwitchLayers = null;
		String acDirectToSwitch = null;
		String setupMove = null;

		aiFaces[0] = r.nextInt(24) + 1; //定为缓冲

		iSecondFace = r.nextInt(9);
		aiFaces[1] = m_astDirectCornerLayers[aiFaces[0]][iSecondFace].theDest;
		pcDirectLayerMove = m_astDirectCornerLayers[aiFaces[0]][iSecondFace].theMove;

		iTemp = r.nextInt(2);
		iSwitchDirectFace = aiFaces[iTemp];
		iDirectOtherFace = aiFaces[1 - iTemp];
		if ( 0 == iTemp ) {
			pcDirectLayerMove = reverse_move(pcDirectLayerMove);
		}
		//System.out.println(String.format("==============direct layer %d %d, move %s, switch direct %d, other %d\r\n", aiFaces[0], aiFaces[1], pcDirectLayerMove, iSwitchDirectFace, iDirectOtherFace));

		acSwitchLayers = calc_switch_layers_corner(pcDirectLayerMove.charAt(0));
		iSwitchLayer = 0;

		iSwitchOthreFace = 0;
		for ( i = r.nextInt(9), iCount = 0; 0 == iSwitchOthreFace && iCount < 9; iCount++, i++ )
		{
			if ( 9 <= i ) i = 0;
			if ( pcDirectLayerMove.charAt(0) == m_astDirectCornerLayers[iSwitchDirectFace][i].theMove.charAt(0) )
			{
				continue;
			}
			if ( 1 < m_astDirectCornerLayers[iSwitchDirectFace][i].theMove.length() && '2' == m_astDirectCornerLayers[iSwitchDirectFace][i].theMove.charAt(1) )
			{
				continue;
			}

			iTemp = m_astDirectCornerLayers[iSwitchDirectFace][i].theDest;
			for ( j = r.nextInt(9), iCount2 = 0; iCount2 < 9; iCount2++, j++ )
			{
				if ( 9 <= j ) j = 0;
				if ( m_astDirectCornerLayers[iTemp][j].theMove.charAt(0) == acSwitchLayers.charAt(iSwitchLayer) )
				{
					iSwitchOthreFace = iTemp;
					acDirectToSwitch = reverse_move(m_astDirectCornerLayers[iSwitchDirectFace][i].theMove);
					break;
				}
			}
		}

		//System.out.println(String.format("===========the othre face %d, switch layer %c, to layer %c\r\n", iSwitchOthreFace, acSwitchLayers.charAt(iSwitchLayer), acDirectToSwitch.charAt(0)));

		for ( i = r.nextInt(9), iCount = 0; iCount < 9; iCount++, i++)
		{
			if ( 9 <= i ) i = 0;
			if ( acSwitchLayers.charAt(iSwitchLayer) != m_astDirectCornerLayers[iSwitchOthreFace][i].theMove.charAt(0) )
			{
				continue;
			}

			iTemp = m_astDirectCornerLayers[iSwitchOthreFace][i].theDest;
			for ( j = r.nextInt(9), iCount2 = 0; iCount2 < 9; iCount2++, j++ ) {
				if ( 9 <= j ) j = 0;
				for ( k = r.nextInt(9), iCount3 = 0; iCount3 < 9; iCount3++, k++ )
				{
					if ( 9 <= k ) k = 0;
					if ( m_astDirectCornerLayers[m_astDirectCornerLayers[iTemp][j].theDest][k].theMove.charAt(0) == acDirectToSwitch.charAt(0) )
					{
						break;
					}
				}

				if ( 9 > iCount3 )
				{
					continue;
				}

				setupMove = m_astDirectCornerLayers[iSwitchOthreFace][i].theMove;
				break;
			}

			if ( 9 > iCount2 )
			{
				break;
			}
		}

		//System.out.println("====setup " + setupMove);
		sol = setupMove + " " + pcDirectLayerMove + " " + reverse_move(acDirectToSwitch) + " " + reverse_move(setupMove) + " " + acDirectToSwitch
				+ " " + reverse_move(pcDirectLayerMove) + " " + reverse_move(acDirectToSwitch) + " " + setupMove + " " + acDirectToSwitch + " " + reverse_move(setupMove);
		//System.out.println("====sol " + sol);
		//System.out.println("====scr " + reverse_move(sol));

		steps[0] = setupMove;
		steps[1] = pcDirectLayerMove;
		steps[2] = reverse_move(acDirectToSwitch) + " " + reverse_move(setupMove) + " " + acDirectToSwitch;
		steps[3] = reverse_move(pcDirectLayerMove);
		steps[4] = reverse_move(acDirectToSwitch) + " " + setupMove + " " + acDirectToSwitch;
		steps[5] = reverse_move(setupMove);

		return reverse_move(sol);
	}

	private String scramble_edge() {
		int aiFaces[] = new int[3];
    	String pcDirectLayerMove = null;
		int iSecondFace, iTemp, iSwitchDirectFace, iDirectOtherFace, iSwitchOthreFace, i, j, k, iSwitchLayer, iCount, iCount2, iCount3;
		String acSwitchLayers = null;
		String acDirectToSwitch = null;
		String setupMove = null;

		aiFaces[0] = r.nextInt(24) + 1; //定为缓冲

		iSecondFace = r.nextInt(9);
		aiFaces[1] = m_astDirectLayers[aiFaces[0]][iSecondFace].theDest;
		pcDirectLayerMove = m_astDirectLayers[aiFaces[0]][iSecondFace].theMove;

		iTemp = r.nextInt(2);
		iSwitchDirectFace = aiFaces[iTemp];
		iDirectOtherFace = aiFaces[1 - iTemp];
		if ( 0 == iTemp ) {
			pcDirectLayerMove = reverse_move(pcDirectLayerMove);
		}
		//System.out.println(String.format("==============direct layer %d %d, move %s, switch direct %d, other %d\r\n", aiFaces[0], aiFaces[1], pcDirectLayerMove, iSwitchDirectFace, iDirectOtherFace));

		acSwitchLayers = calc_switch_layers(pcDirectLayerMove.charAt(0));
		iSwitchLayer = r.nextInt(2);

		iSwitchOthreFace = 0;
		for ( i = r.nextInt(9), iCount = 0; 0 == iSwitchOthreFace && iCount < 9; iCount++ , i++)
		{
			if ( 9 <= i ) i = 0;
			if ( pcDirectLayerMove.charAt(0) == m_astDirectLayers[iSwitchDirectFace][i].theMove.charAt(0) )
			{
				continue;
			}
			if ( 1 < m_astDirectLayers[iSwitchDirectFace][i].theMove.length() && '2' == m_astDirectLayers[iSwitchDirectFace][i].theMove.charAt(1) )
			{
				continue;
			}

			iTemp = m_astDirectLayers[iSwitchDirectFace][i].theDest;
			for ( j = r.nextInt(9), iCount2 = 0; iCount2 < 9; iCount2++, j++ )
			{
				if ( 9 <= j ) j = 0;
				if ( m_astDirectLayers[iTemp][j].theMove.charAt(0) == acSwitchLayers.charAt(iSwitchLayer) )
				{
					iSwitchOthreFace = iTemp;
					acDirectToSwitch = reverse_move(m_astDirectLayers[iSwitchDirectFace][i].theMove);
					break;
				}
			}
		}

		//System.out.println(String.format("===========the othre face %d, switch layer %c, to layer %c\r\n", iSwitchOthreFace, acSwitchLayers.charAt(iSwitchLayer), acDirectToSwitch.charAt(0)));

		for ( i = r.nextInt(9), iCount = 0; iCount < 9; iCount++, i++)
		{
			if ( 9 <= i ) i = 0;
			if ( acSwitchLayers.charAt(iSwitchLayer) != m_astDirectLayers[iSwitchOthreFace][i].theMove.charAt(0) )
			{
				continue;
			}

			iTemp = m_astDirectLayers[iSwitchOthreFace][i].theDest;
			for ( j = r.nextInt(9), iCount2 = 0; iCount2 < 9; iCount2++, j++ ) {
				if ( 9 <= j ) j = 0;
				for ( k = r.nextInt(9), iCount3 = 0; iCount3 < 9; iCount3++, k++ )
				{
					if ( 9 <= k ) k = 0;
					if ( m_astDirectLayers[m_astDirectLayers[iTemp][j].theDest][k].theMove.charAt(0) == acDirectToSwitch.charAt(0) )
					{
						break;
					}
				}

				if ( 9 > iCount3 )
				{
					continue;
				}

				setupMove = m_astDirectLayers[iSwitchOthreFace][i].theMove;
				break;
			}

			if ( 9 > iCount2 )
			{
				break;
			}
		}

		//System.out.println("====setup " + setupMove);
		sol = setupMove + " " + pcDirectLayerMove + " " + reverse_move(acDirectToSwitch) + " " + reverse_move(setupMove) + " " + acDirectToSwitch
			+ " " + reverse_move(pcDirectLayerMove) + " " + reverse_move(acDirectToSwitch) + " " + setupMove + " " + acDirectToSwitch + " " + reverse_move(setupMove);
		//System.out.println("====sol " + sol);
		//System.out.println("====scr " + reverse_move(sol));

		steps[0] = setupMove;
		steps[1] = pcDirectLayerMove;
		steps[2] = reverse_move(acDirectToSwitch) + " " + reverse_move(setupMove) + " " + acDirectToSwitch;
		steps[3] = reverse_move(pcDirectLayerMove);
		steps[4] = reverse_move(acDirectToSwitch) + " " + setupMove + " " + acDirectToSwitch;
		steps[5] = reverse_move(setupMove);

		return reverse_move(sol);
	}

	public String getResolve(String scr)
	{
		return "Setup: " + steps[0] + "\nA: " + steps[1] + "\nB: " + steps[2] + "\nA': " + steps[3] + "\nB': " + steps[4] + "\nReverse: " + steps[5];
	}
}
